package com.burges.net.ml.supervisedLearning

import org.apache.flink.api.scala.{DataSet, ExecutionEnvironment}
import org.apache.flink.ml.common.LabeledVector
import org.apache.flink.ml.regression.MultipleLinearRegression

/**
  * 创建人    BurgessLee 
  * 创建时间   2020/2/27 
  * 描述     多元线性回归应用实例
  */
object MultipleLinearRegressionDemo {

	def main(args: Array[String]): Unit = {
		val environment = ExecutionEnvironment.getExecutionEnvironment
		// 创建多元线性回归学习器
		val multipleLinearRegression = MultipleLinearRegression()
        		.setIterations(10)
        		.setStepsize(0.5)
        		.setConvergenceThreshold(0.001)
		//创建训练集和测试集
		val trainLibSvmFile: String = ""
		val testLibSvmFile: String = ""
		val trainingDS: DataSet[LabeledVector]  = environment.readMultipleLinearRegressionFile(trainLibSvmFile)
		val testingDS: DataSet[Vector] = environment.readMultipleLinearRegressionFile(testLibSvmFile)
		//将定义好的模型适配到数据集上进行模型训练
		multipleLinearRegression.fit(trainingDS)
		//使用测试数据集进行模型预测，产生预测结果
		val predictDs: DataSet[Any] = multipleLinearRegression.predict(testingDS)

	}

}
